<?php
  require '../include/library.inc.php';
  require '../include/admin_login.inc.php';
  
  $image_id = $_GET['image_id'];
  $school_id = $_GET['school_id'];

  if($image_id) {
	  
	$sql = "SELECT
			  filename
			FROM
			  images
			WHERE
			  image_id = ".$image_id." 
              ";
	$row = mysql_fetch_assoc(query($sql));
	$filename = $row['filename'];
	
	if (unlink("../uploads/img/".$filename)) {
		
		$sql = "DELETE FROM 
				   images
				WHERE
				   image_id = ".$image_id." 
				 ";
		query($sql);
	
		redirect("school_edit.php?school_id=".$school_id."#images");
		
	}
  }
  
  redirect("schools.php");  
?>